/*
 * Copyright 2008, Myron Marston <myron DOT marston AT gmail DOT com>
 *
 * This file is part of Fractal Composer.
 *
 * Fractal Composer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * at your option any later version.
 *
 * Fractal Composer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Fractal Composer.  If not, see <http://www.gnu.org/licenses/>. 
 */

package com.myronmarston.music.settings;

import org.simpleframework.xml.*;

/**
 * Used as a hash key to access a particular VoiceSection.
 * 
 * @author Myron
 */
@Root
public class VoiceSectionHashMapKey {
    @Element
    private Voice voice;
    
    @Element
    private Section section;
    
    /**
     * Constructor.
     * 
     * @param voice the Voice for this key
     * @param section the Section for this key
     */
    public VoiceSectionHashMapKey(Voice voice, Section section) {
        this.voice = voice;
        this.section = section;
    }    
    
    /**
     * Provided for xml deserialization.
     */
    private VoiceSectionHashMapKey() {}
    
    /**
     * Gets the Section for this key.
     * 
     * @return the Section for this key
     */
    public Section getSection() {
        return section;
    }

    /**
     * Gets the Voice for this key.
     * 
     * @return the Voice for this key
     */
    public Voice getVoice() {
        return voice;
    }

    // equals() and hashCode() were generated by Netbeans IDE.
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final VoiceSectionHashMapKey other = (VoiceSectionHashMapKey) obj;
        if (this.voice != other.voice && (this.voice == null || !this.voice.equals(other.voice))) {
            return false;
        }
        if (this.section != other.section && (this.section == null || !this.section.equals(other.section))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 41 * hash + (this.voice != null ? this.voice.hashCode() : 0);
        hash = 41 * hash + (this.section != null ? this.section.hashCode() : 0);
        return hash;
    }        
}
